GADTs and Exhaustiveness: Looking for the Impossible

نویسندگان

  • Jacques Garrigue
  • Jacques Le Normand
چکیده

Sound exhaustiveness checking of pattern-matching is an essential feature of GADTs, and OCaml has supported it from day one, by showing that the remaining cases could never be typed [1]. Not only does it allow the programmer to be confident in the soundness of his code, but it also permits optimizations which make GADTs more efficient. However, while this approach is sound and can prune some simple uses of GADTs, some other uses caused superfluous warnings. In this talk we describe the original approach and how we ensure its soundness, and show that one can do better by turning the type-checking of extra cases into a backtracking proof search algorithm. We also show that the exhaustiveness problem is undecidable for GADTs, so that this proof search must be kept partial.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Type inference for GADTs via Herbrand constraint abduction

Type inference for Hindley/Milner and variants is well understood as a constraint solving problem. Recent extensions to Hindley/Milner such as generalized algebraic data types (GADTs) force us to go beyond this approach to inference. In this paper we show how to perform type inference for GADTs using Herbrand constraint abduction, a solving method to infer missing facts in terms of Herbrand con...

متن کامل

Thyroid Nodule Imaging. Status and Limitations.

Thyroid nodules are common, occurring in almost two-thirds of some populations; among these only about 7% are malignant. The most important question with any new discovered thyroid nodule is, “is this malignant?” The main arbiter of malignancy or benignity remains fine needle aspiration and the mainstay of treatment surgery. But given the resources involved, doing an FNAC or surgery in every di...

متن کامل

First-class subtypes

One purpose of the ML module system is to hide equalities between types exposed in an interface and types used in the implementation [10]. Generalized algebraic data types (gadts) [13], a more recent addition, make these type equalities first class. gadts attach first class equalities to data; equalities may be hidden by polymorphism or modular abstraction, and later revealed by scrutinising th...

متن کامل

Ambivalent Types for Principal Type Inference with GADTs

GADTs, short for Generalized Algebraic DataTypes, which allow constructors of algebraic datatypes to be non-surjective, have many useful applications. However, pattern matching on GADTs introduces local type equality assumptions, which are a source of ambiguities that may destroy principal types— and must be resolved by type annotations. We introduce ambivalent types to tighten the definition o...

متن کامل

Tracing ambiguity in GADT type inference

GADTs, short for Generalized Algebraic DataTypes, extend usual algebraic datatypes with a form of dependent typing that has many useful applications, but raises serious issues for type inference. Pattern matching on GADTs introduces type equalities with limited scopes, which are a source of ambiguities that may destroy principal types—and must be resolved by type annotations. By tracing ambigui...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2015